<template>
  <div class="container">
    <swiper :pagination="true" class="mySwiper">
      <swiper-slide v-for="i in 3" :key="i">
        <ul>
          <li
            v-for="(item, index) in imgArr.slice((i - 1) * 10, i * 10)"
            :key="index"
          >
            <img :src="item.img" />
            <p>{{ item.desc }}</p>
          </li>
        </ul>
      </swiper-slide>
    </swiper>
    <article>
      <p>
        <img
          src="https://x.dscmall.cn/storage/data/gallery_album/177/original_img/177_P_1597978466633.png"
        />
        <span v-for="(item, index) in articleArr" :key="index">
          {{ index === 0 ? item.title : "" }}
        </span>
      </p>
      <i>icon</i>
    </article>
  </div>
</template>
<script>
import { Swiper, SwiperSlide } from "swiper/vue";
import "swiper/swiper.less";
import "swiper/components/pagination/pagination.min.css";

import store from "../../store/index.js";

import { ref, computed } from "vue";

export default {
  setup() {
    const imgArr = computed(() => {
      if (store.getters.haveViewData === true) {
        const list = store.getters.findViewData("nav")[0].data.list;
        return list;
      }
      return [];
    });
    const articleArr = computed(() => {
      if (store.getters.haveArticleData === true) {
        const list = store.state.home.articleData;
        return list;
      }
      return [];
    });
    return {
      imgArr,
      articleArr,
    };
  },
  components: {
    Swiper,
    SwiperSlide,
  },
};
</script>

<style lang="less" scoped>
.container {
  margin: 1rem 1rem 0;
  padding: 0;
  border-radius: 1rem;
  background-color: #fff;
  .mySwiper {
    width: 100%;
    padding-bottom: 30px;
    /deep/ .swiper-pagination-bullet {
      width: 15px;
      height: 4px;
      background: linear-gradient(-88deg, #ff4f2d, #f91f27);
      opacity: 0.2;
      margin: 0;
    }
    /deep/ .swiper-pagination-bullet:nth-child(1) {
      border-radius: 2px 0 0 2px;
    }
    /deep/ .swiper-pagination-bullet:nth-child(2) {
      border-radius: 0;
    }
    /deep/ .swiper-pagination-bullet:nth-child(3) {
      border-radius: 0 2px 2px 0;
    }
    /deep/ .swiper-pagination-bullet-active {
      opacity: 1;
      border-radius: 2px !important;
    }
    /deep/ .swiper-slide {
      width: 100% !important;
      ul {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        li {
          width: 20%;
          text-align: center;
          font-size: 1.3rem;
          color: #000;
          img {
            width: 100%;
          }
          p {
            margin-top: 0.2rem;
          }
        }
      }
    }
  }
  article {
    margin: 0 1rem;
    height: 5rem;
    border-top: 1px solid #ededed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    p {
      box-sizing: border-box;
      padding: 0.7rem 0;
      height: 100%;
      display: flex;
      align-items: center;
      margin: 0;
      img {
        height: 86%;
        margin-right: 0.8rem;
      }
      span {
        font-size: 1.3rem;
      }
    }
  }
}
</style>
